import { GSprite } from "../../../../../com/mui/controls/GSprite";
import { DefInfo } from "../../../resource/info/DefInfo";
import { ObjCreate } from "../../common/ObjCreate";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { FlyFootBmp } from "../flyFoot/FlyFootBmp";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../resource/ImagesConst";
import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { ResFileConst } from "../../../resource/ResFileConst";
import { Language } from "../../../../../extend/language/Language";
import { TaskTargetInfo } from "../../../model/TaskTargetInfo";
import { EntityType } from "../../../rules/EntityType";
import { SceneConfig } from "../../../resource/SceneConfig";
import { AIManager } from "../../../scene/ai/AIManager";
import { Cache } from "../../../cache/Cache";
import { GameController } from "../../../mvc/GameController";
import { AIType } from "../../../scene/ai/AIType";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
type int = number;
//class HotTransferRenderer
    
    export  class HotTransferRenderer extends GSprite
    {
        constructor(arg1: int, arg2: DefInfo)
        {
            super();
            this._index = arg1;
            this._defInfo = arg2;
            return;
        }

        protected /* override */ createDisposedChildrenImpl(): void
        {
            var loc2=null;
            ObjCreate.createBitmap("PackItemBg", 0, 0, this);
            this._item = new Object /* flash.display.Bitmap */();
            this._nameTxt = ObjCreate.createGTextField("", 47, 2, 100, 20, this, GlobalStyle.textFormatWhite);
            this._positionTxt = ObjCreate.createGTextField("", 47, 20, 58, 20, this);
            this._positionTxt.addEventListener(flash.events.TextEvent.LINK, this.onOptLinkclickHandler);
            var loc1=new FlyFootBmp();
            ObjCreate.setObjAttri(loc1, 105, 20, -1, -1, this);
            loc1.addEventListener(flash.events.MouseEvent.CLICK, this.onFlyFootClickHandler);
            if (this._index != 5) 
            {
                loc2 = GlobalClass.getBitmap(ImagesConst.Line);
                ObjCreate.setObjAttri(loc2, -22, 45, 200, -1, this);
            }
            LoaderHelp.addResCallBack(ResFileConst.mapUI, this.onMapUIResLoadedHandler);
            return;
        }

        /* internal  */onMapUIResLoadedHandler(): void
        {
            var loc1=null;
            var loc2=null;
            if (this._defInfo) 
            {
                this._item.bitmapData = GlobalClass.getBitmapData("MapUIPlace_" + this._index);
                ObjCreate.setObjAttri(this._item, 3, 3, 32, 32, this);
                this._nameTxt.text = this._defInfo.name;
                this._positionTxt.htmlText = Language.getStringByParam(20165, this._defInfo.text1);
                loc1 = this._defInfo.text1.split(",");
                this._target = new TaskTargetInfo();
                this._target.x = loc1[0];
                this._target.y = loc1[1];
                this._target.mapId = this._defInfo.value;
                this._target.targetType = EntityType.Point;
                loc2 = SceneConfig.instance.getSceneInfo(this._target.mapId);
                if (loc2) 
                {
                    this._target.mapName = loc2.sMapDefine.name;
                }
            }
            return;
        }

        /* internal  */onOptLinkclickHandler(arg1: Object /* flash.events.TextEvent */): void
        {
            AIManager.onAutoPathAIControl(this._target);
            if (Cache.instance.mapui.autoCloseMap) 
            {
                GameController.bigMap.view.hide();
            }
            return;
        }

        /* internal  */onFlyFootClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            AIManager.onAIControl(this._target, AIType.AI_Convey);
            if (Cache.instance.mapui.autoCloseMap) 
            {
                GameController.bigMap.view.hide();
            }
            return;
        }

        /* internal */ /* var */_item: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_nameTxt: GTextFiled;

        /* internal */ /* var */_positionTxt: GTextFiled;

        /* internal */ /* var */_index: int;

        /* internal */ /* var */_defInfo: DefInfo;

        /* internal */ /* var */_target: TaskTargetInfo;
    }
